package com.ying.tests.CCCbasis.Test5ThreadPool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 使用Callable接口创建线程池
 */
public class Test5CallablePool {
    public static void main(String[] args) {
        ExecutorService executorService = Executors.newFixedThreadPool(3);
        TaskCallable task= new TaskCallable();
        // 线程池中获取线程对象，调用run方法
        executorService.submit(task);// 10000个任务
        // 再获取一个线程对象
        executorService.submit(task);// 10000个任务
        // 关闭线程池
        executorService.shutdown();

    }
}
